<template>
    <bi-form>
        <bi-form-group label="发送方式">
            <bi-radio v-model="sendType" :option="sendTypeOption"></bi-radio>
        </bi-form-group>

        <bi-form-group v-if="sendType=='member'" label="指定用户">
            <bi-textarea v-model="sendMember" placeholder="请输入用户手机号,每行一个"></bi-textarea>
        </bi-form-group>
    </bi-form>
</template>

<script>
export default{
    dialog:{
        width:500,
        title:'发送优惠价'
    },
    data(){

        let sendTypeOption = [
            {value:'member','label':'指定用户'},
            {value:'member-level','label':'指定用户等级'},
            {value:'all','label':'全部用户'}
        ];
        let  sendMember =  '';
        let sendType = 'member';

        if (this.member){
            sendMember = this.member;
            sendType = 'member';
        }

        return {
            sendTypeOption,
            sendMember,
            sendType
           
        }
    },
    props:['id','member'],
    methods:{
        dialogOk(){
            this.$ajax({
                url:this.$url({'app':'shop','controller':'admin.coupon','action':'send'}),
                data:{
                    coupon_id:this.id,
                    sendType:this.sendType,
                    sendMember:this.sendMember
                },
                success:()=>{
                    this.$toast('发送成功');
                    this.$emit('update:send',true);
                }
            })
        }
    }
}
</script>